Data Types

Data types are actually classes and variables are instance (object) of these classes.

Python also provides some built-in data types, in particular, dict, list, set and frozenset, and tuple. The str class is used to hold Unicode strings, and the bytes class is used to hold binary data.


Following are the python data types:


Numbers


  1. int:
    • this one is pretty standard -- plain integers are just positive or negative whole numbers.

      example:

      >>>a = 100
      >>>print(type(a))
      #prints class 'int'
  2. float:
    • floats represent real numbers, but are written with decimal points (or scientific notaion) to divide the whole number into fractional parts.

      >>>a = 45.67
      >>>print(type(a))
      #prints class 'float'
  3. complex:
    • represented by the formula a + bJ, where a and b are floats, and J is the square root of -1 (the result of which is an imaginary number). Complex numbers are used sparingly in Python.

      >>>a = 3.14J
      >>>print(type(a))
      #prints class 'complex'

#practice the above programs here #create a variables #assign a value #print type of value in the variable
Just press 'Run'.